<?php
require_once dirname(__FILE__) . '/../../common.inc.php';
try {
  $hostname = DB_HOST;
  $username = DB_LOGIN;
  $password = DB_PASS;
  $dbname = DB_NAME;
  $myPdo = new PDO ('mysql:host=' . $hostname, $username, $password);
  $myPdo->exec('USE ' . $dbname);
  $myPdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  $sql = "CREATE TABLE IF NOT EXISTS `pz_knowledge`(
           `id` int NOT NULL AUTO_INCREMENT PRIMARY KEY,
           `track_id` varchar(16) UNIQUE,
           `title` varchar(64),
           `link` varchar(512),
           `intro` text,
           `type` varchar(64),
           `detail` text
          )";
  $myPdo->exec($sql);
  $sql = "CREATE TABLE IF NOT EXISTS `pz_tnfc_knowledge_image`(
           `id` int NOT NULL AUTO_INCREMENT PRIMARY KEY,
           `track_id` varchar(16) UNIQUE,
           `knowledge_trackId` varchar(64),
           `name` varchar(128),
           `name_on_server` varchar(64) UNIQUE,
           `size` float,
           `width` float,
           `height` float,
           `link` varchar(512)
          )";
  $myPdo->exec($sql);
  echo 'Completed Successfully.';
} catch (PDOException $e) {
  echo ERROR_SIGN . $e->getMessage();
}
?>
